# -*-coding:utf-8-*-
from util.ReslutReturn import *
from . import app
from . import db

@app.route("/testDb")
def testDb():
    e = 1/0
    userList = CbyUser.query.all()
    userDictList = []
    for i in range(len(userList)):
        userDictList.append(userList[i].asDict())
    print(userDictList)
    return ok("查询成功",userDictList)

# 创建数据库模型类
class CbyUser(db.Model):
    """
    user表
    """
    __tablename__ = "cby_user"
    id = db.Column(db.String,primary_key=True)
    name = db.Column(db.String)
    nick_name = db.Column(db.String)
    password = db.Column(db.String)
    email = db.Column(db.String)
    phone = db.Column(db.String)
    identity_id = db.Column(db.String)
    detail = db.Column(db.String)
    insert_time = db.Column(db.String)
    update_time = db.Column(db.String)
    def asDict(self):
        return {"id":self.id,"name":self.name,"nick_name":self.nick_name,"password":self.password,"email":self.email,"phone":self.phone,"identity_id":self.identity_id,"detail":self.detail}